# 多阶段构建： build project
FROM golang:1.20 AS builder
ENV GOPROXY https://goproxy.cn
ENV GOOS linux
ENV GOARCH amd64
WORKDIR /project
COPY * /project/
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -v -o app

FROM alpine:3.17
# 修改alpine为国内源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
  apk update && \
  apk upgrade && \
  apk add --update --no-cache ca-certificates tzdata && \
  rm -rf /var/cache/apk/*
ENV TZ=Asia/Shanghai
WORKDIR /project
COPY --from=builder /project/app .
ENTRYPOINT ["/project/app"]
